<%@ page import="web.servlet.eljstl.User" %>
<%@ page import="java.util.*" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/6/11
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h2>JSP简单用法</h2>
<%-- java--%>
<% String s1="hello jsp";
    System.out.println(s1);
%>
<h4>
    <%=s1%>
</h4>
<h2>EL表达式</h2>
<%--简化和替换jsp页面的java代码--%>
<h2>EL运算</h2>
${1+2}
<h2>判断是否为空empty</h2>
${empty str}
<h2>能从域对象获取值</h2>
<%
    request.setAttribute("msg","dg");
    request.getSession().setAttribute("msg","df");
%>
<%--若不指定默认request--%>
${msg}
${sessionScope.msg}
<%
    User user=new User("张三",123,new Date());
    request.setAttribute("u",user);
    List<String> list=new ArrayList<String>();
    list.add("lisf");
    list.add("dsvf");
    request.setAttribute("list",list);
    Map<String,User> map=new HashMap<String, User>();
    map.put("sdg",user);
    request.setAttribute("map",map);

%>
<%--从域对象中获取
实质：调用getter方法--%>
${u}<br>
${u.name}<br>
${u.birthday}<br>
${u.birthday.month}<br>
${u.birStr}<br>
<h2>获取list的值</h2>
${list}<br>
${list[1]}<br>
<h2>获取map的值</h2>
${map}<br>
${map.sdg}<br>
<h>动态获取项目路径</h>
<%=request.getContextPath()%><br>
${pageContext.request.contextPath}

</body>
</html>
